package practice;

public class Cal {
    private static int x=100;
    double a;
    double b;
    char c;
    double an;

    public static void main(String[] args) {
        Cal cal1 = new Cal();
        System.out.println(cal1.x);
        cal1.x++;
        System.out.println(cal1.x);
        Cal cal2 = new Cal();
        System.out.println(cal2.x);
        cal1 = new Cal();
        System.out.println(cal1.x);
        Cal.x++;
        System.out.println(cal1.x);
    }
    public Cal(){
    }
    public Cal(double a,double b,char c){
        this.a = a;
        this.b = b;
        this.c = c;
    }
    public double getAn(){
        switch(c){
            case '+' :
                add(a,b);
                break;
            case '-' :
                jian(a,b);
                break;
            case '*' :
                cheng(a,b);
                break;
            case '/' :
                chu(a,b);
                break;
            default :
                System.out.println("不是加减乘除");
        }
        return this.an;
    }
    public void add(double a, double b){
        this.an = a+b;
    }
    public void jian(double a, double b){
        this.an = a-b;
    }
    public void chu(double a, double b){
        if (b==0){
            System.out.println("除数为0，无法计算");
            this.an=0;
            return;
        }
        this.an = a/b;
    }
    public void cheng(double a, double b){
        this.an = a*b;
    }
}
